<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>节流</title>
</head>
<body>
    <script>
        //   指定时间间隔内只会执行一次任务；

        function throttle(fn,tim){
            let flag=true;
            return function(){
                if(!flag) return;
                flag=false;
                setTimeout(()=>{
                    fn;
                    flag=true;
                },tim);
            }
        }
    </script>
</body>
</html>